﻿#include "capcontrolwidget.h"
#include <qgridlayout.h>
#include <qfile.h>
#include <QRegExpValidator>

QCAPControlWidget::QCAPControlWidget(QString sIPAdd,int nSendPort,int nRcvPort,QWidget *parent) : QWidget(parent)
{
    _pCapControl = CCapControl::getInstance();
//    _pCapControl->startRcvData(sIPAdd,nSendPort,nRcvPort);

    InitUI();

    connect(_pCapControl,&CCapControl::signal_rcvdata,_pCAPParamBarWidget,&QCAPParamBarWidget::onRcvData);
    connect(_pCapControl,&CCapControl::signal_rcvdata,_pCapStatusWidget,&QCapStatusWidget::onRcvData);

    connect(_pCapControl,&CCapControl::signal_rcvdata,_pAZIPlotDataWidget,&QPlotDataWidget::onRcvData);
    connect(_pCapControl,&CCapControl::signal_rcvdata,_pPitchPlotDataWidget,&QPlotDataWidget::onRcvData);

 }

/******************************************
* 功能:析构
* 输入:
* 输出:
* 返回值:
* 维护记录:
******************************************/
QCAPControlWidget::~QCAPControlWidget()
{

}
/**
* @brief 初始化界面
* @note
*
*/
void QCAPControlWidget::InitUI()
{
    _pCapStatusWidget = new QCapStatusWidget();
    _pCAPParamBarWidget = new QCAPParamBarWidget();
    _pAZIPlotDataWidget = new QPlotDataWidget(M_AXIS_AZI,"方位轴");
    _pPitchPlotDataWidget = new QPlotDataWidget(M_AXIS_PICTH,"俯仰轴");

    _pAZIBodDataWidget = new QBodPlotWidget(M_AXIS_AZI,"方位轴");
    _pPitchBodDataWidget = new QBodPlotWidget(M_AXIS_PICTH,"俯仰轴");

    _pTabWidget = new QTabWidget(this);
    _pTabWidget->setStyleSheet("QTabWidget:pane {border-top:0px solid #e8f3f9;background:transparent; }");
    _pTabWidget->setTabPosition(QTabWidget::South);
    _pTabWidget->addTab(_pAZIPlotDataWidget,"方位轴");
    _pTabWidget->addTab(_pPitchPlotDataWidget,"俯仰轴");
    _pTabWidget->addTab(_pAZIBodDataWidget,"方位轴波特图");
    _pTabWidget->addTab(_pPitchBodDataWidget,"俯仰轴波特图");


    QGridLayout* pLayout = new QGridLayout(this);
    pLayout->addWidget(_pCAPParamBarWidget,0,0,2,1);
    pLayout->addWidget(_pCapStatusWidget,0,1,1,1);
    pLayout->addWidget(_pTabWidget,1,1,1,1);


    pLayout->setColumnStretch(0,2);
    pLayout->setColumnStretch(1,5);

    pLayout->setRowStretch(0,3);
    pLayout->setRowStretch(1,4);

    pLayout->setSpacing(0);
    pLayout->setMargin(0);
}

